#ifndef HTTPMGR_H
#define HTTPMGR_H

#include<QUrl>
#include "singleton.hpp"
#include"global.h"

//创建单例网络类
class HttpMgr : public QObject, public Singleton<HttpMgr>
    ,public std::enable_shared_from_this<HttpMgr>//用来实现伪闭包
{
    Q_OBJECT
    friend class Singleton<HttpMgr>;
public:
    ~HttpMgr();
    void PostHttpReq(QUrl &&url, QByteArray &&data, ReqId id, Modules mod);

private:
    HttpMgr();

private slots:
    void HttpFinish(ReqId id, QByteArray res, Modules mod, ErrorCodes err);

signals:
    void sig_http_finish(ReqId id, QString res, Modules mod, ErrorCodes err);//需要吗？
    void sig_find_mod_finish(QByteArray, ReqId, ErrorCodes);

    void sig_reg_mod_finish(QByteArray, ReqId, ErrorCodes);
    void sig_login_mod_finish(QByteArray, ReqId, ErrorCodes);
    void sig_global_mod_finish(QByteArray, ReqId, ErrorCodes);
private:
    QNetworkAccessManager manager{};
};

#endif // HTTPMGR_H
